package com.yuantu.judiciary.model.word;

import lombok.Data;
import org.apache.poi.xwpf.usermodel.XWPFTableRow;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTHeight;
import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTrPr;

import java.math.BigInteger;
import java.util.List;

/**
 * @author kgwei
 * 表格的行
 */
@Data
public class WordTableRow {

    private List<WordTableCell> cells;

    /**
     * set row height; units = twentieth of a point, 360 = 0.25"
     */
    private Long height;

    public static WordTableRow defaultRow() {
        WordTableRow wordTableRow = new WordTableRow();
        wordTableRow.setHeight(WordDefaultValue.TABLE_ROW_HEIGHT);
        return wordTableRow;
    }

    public void rowBuild(XWPFTableRow row) {
        if (height != null) {
            CTTrPr trPr = row.getCtRow().addNewTrPr();
            CTHeight ht = trPr.addNewTrHeight();
            ht.setVal(BigInteger.valueOf(height));
        }
    }
}
